<?php
/**
 * Created by PhpStorm.
 * User: sks
 * Date: 2015/12/15
 * Time: 13:49
 */

/**
 * Class Involved_AdminModel
 */

class Involved_MailModel extends BaseModel{

    protected $table = 'mail';
    /**
     * 站内信列表
     * @return mixed
     */
    public function MessageMail($uid)
    {
        return  DB::table($this->table)
                ->select('mail_id','mail.user_id','title','content','mail.add_time','user_nick','admin_id','statue')
                ->LeftJoin('admin_user','admin_user.user_id','=','mail.admin_id')
                ->orwhere(['mail.user_id'=>$uid])
                ->orwhere(['mail.admin_id'=>$uid])
                ->orderby('mail.add_time','desc')->get();
    }
    /**
     * 站内信详情页
     * @return mixed
     */
    public function MailContent($mail_id)
    {
        return  DB::table($this->table)
            ->select('mail_id','mail.user_id','title','content','mail.add_time','user_nick','admin_id','statue')
            ->LeftJoin('admin_user','admin_user.user_id','=','mail.admin_id')
            ->where(['mail.mail_id'=>$mail_id])
            ->first();
    }
    /**
     * 站内信统计展示
     * @return mixed
     */
    public function MailCount($uid)
    {
        return  DB::table($this->table)
            ->select('mail_id','mail.user_id','title','content','mail.add_time','user_nick','admin_id','statue')
            ->LeftJoin('admin_user','admin_user.user_id','=','mail.admin_id')
            ->where(['mail.admin_id'=>$uid,'statue'=>0])
            ->count();
    }




}